//
//  String+Extension.swift
//  TheWatermark
//
//  Created by 沙睿 on 2021/6/6.
//

import Foundation

extension String {
    
    public func sr_subString(from index: Int) -> String {
        if index >= self.count || index < 0 {
            return ""
        }
        return String(self[self.index(self.startIndex, offsetBy: index)..<self.endIndex])
    }
    
    public func sr_subString(_ range: NSRange) -> String {
        
        let start = range.location
        let length = range.length
        if (start + length) > self.count{
            return ""
        }
        return String(self[self.index(self.startIndex, offsetBy: start)..<self.index(self.startIndex, offsetBy: start + length)])
    }
}
